<template>
  <div class="apply">
    <div class="caozuo">
      <div></div>
      <div>
        <el-button type="primary" size="mini" icon="el-icon-edit" :disabled="disabled">通过审核</el-button>
        <el-button type="primary" size="mini" icon="el-icon-edit" :disabled="disabled">驳回</el-button>
        <el-button type="primary" size="mini" icon="el-icon-edit" :disabled="disabled">删除</el-button>
      </div>
    </div>
    <div class="table">
      <el-table
        ref="multipleTable"
        :data="tableData"
        tooltip-effect="dark"
        style="width: 100%"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55"></el-table-column>

        <el-table-column prop="name" label="奖项名称" width="120"></el-table-column>
        <el-table-column prop="name" label="奖项类别" width="120"></el-table-column>
        <el-table-column prop="name" label="参评单位" width="120"></el-table-column>
        <el-table-column prop="name" label="完整度" width="120"></el-table-column>
        <el-table-column prop="name" label="评审情况" width="120"></el-table-column>
        <el-table-column prop="name" label="获奖情况" width="120"></el-table-column>
        <el-table-column label="操作">
          <el-button
            type="primary"
            size="mini"
            icon="el-icon-share"
            @click="handledetails(scope.row)"
          >浏览</el-button>
          <el-button type="primary" size="mini" icon="el-icon-edit" @click="handleput(scope.row)">退回</el-button>
          <el-button type="primary" size="mini" icon="el-icon-edit" @click="handleput1()">修改获奖情况</el-button>
        </el-table-column>
      </el-table>
    </div>
    <el-dialog title="修改密码" :visible.sync="dialogFormVisible" width="30%">
      <el-form :model="form">
        <el-form-item label="旧密码" :label-width="formLabelWidth">
          <el-input v-model="form.mima" autocomplete="off" placeholder="请输入旧密码"></el-input>
        </el-form-item>
        <el-form-item prop="phones" label="新密码" :label-width="formLabelWidth">
          <el-input
            oninput="value=value.replace(/[\W]/g,'')"
            maxlength="20"
            type="password"
            v-model="form.password"
            placeholder="请输入密码"
          />
        </el-form-item>
        <el-form-item prop="phones" label="新密码" :label-width="formLabelWidth">
          <el-input
            oninput="value=value.replace(/[\W]/g,'')"
            maxlength="20"
            type="password"
            v-model="form.password1"
            placeholder="请再次输入密码"
            @blur="Verification"
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  data() {
    return {
      formLabelWidth: "80px",
      form: {
        mima: "",
        password1: "",
        password: "",
      },
      dialogFormVisible: false,
      disabled: true,
      tableData: [
        {
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "2016-05-02",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "2016-05-04",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "2016-05-01",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "2016-05-08",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "2016-05-06",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "2016-05-07",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄",
        },
      ],
      multipleSelection: [],
    };
  },

  components: {},

  methods: {
    Verification() {
      if (this.form.password.length >= 6) {
        if (this.form.password1 != this.form.password) {
          this.$message({
            message: "两次密码不一致请重新输入",
            type: "error",
          });
          this.form.password1 = "";
        }
      } else {
        this.form.password = "";
        this.form.password1 = "";
        this.$message({
          message: "密码最低为6位数",
          type: "error",
        });
      }
    },
    handledetails(e) {},
    handleput(e) {},
    handleput1(e) {
      this.dialogFormVisible = true;
      this.form = {};
    },
    handleDel(e) {},
    toggleSelection(rows) {
      if (rows) {
        rows.forEach((row) => {
          this.$refs.multipleTable.toggleRowSelection(row);
        });
      } else {
        this.$refs.multipleTable.clearSelection();
      }
    },
    handleSelectionChange(val) {
      console.log(val);
      if (val.length == this.tableData.length) {
        this.disabled = false;
      } else {
        this.disabled = true;
      }
      this.multipleSelection = val;
    },
  },
};
</script>

<style scoped>
.apply {
  width: 100%;
  height: 100%;
  background-color: #fff;
  overflow: hidden;
}
.table {
  width: 95%;
  height: 80%;
  margin: 0 auto;
  overflow-y: scroll;
}
.caozuo {
  box-sizing: border-box;
  padding: 20px;
  display: flex;
  justify-content: space-between;
}
</style>